package  
{
	import flash.display.Sprite;
	import flash.net.SharedObject;
	import flash.utils.ByteArray;
	import Layouts.*;
	
	public class Game_Manager 
	{
		private var par:Main;
		private var current_screen:Sprite;
		private	var new_screen:Sprite;
		public var game_files:SharedObject;
		
		[Embed(source = "Resources/Texts/Perro.txt",mimeType="application/octet-stream")]
		private var dog_text:Class;
		[Embed(source = "Resources/Texts/Cocodrilo.txt",mimeType="application/octet-stream")]
		private var croc_text:Class;
		[Embed(source="Resources/Texts/Toro.txt",mimeType="application/octet-stream")]
		private var bull_text:Class;
		
		private var rnd_num:Number;
		
		public var title:String;
		public var text:String;
		public var question1:String;
		public var q1answer1:String;
		public var q1answer2:String;
		public var q1answer3:String;
		public var q1answer4:String;
		public var question2:String;
		public var q2answer1:String;
		public var q2answer2:String;
		public var q2answer3:String;
		public var q2answer4:String;
		public var question3:String;
		public var q3answer1:String;
		public var q3answer2:String;
		public var q3answer3:String;
		public var q3answer4:String;
		
		public var right_answer1:uint;
		public var right_answer2:uint;
		public var right_answer3:uint;
		
		public function Game_Manager(parent:Main):void {
			par = parent;
			game_files = SharedObject.getLocal("Arreglacaminos");
			goToScreen("MainMenu");
		}
		
		public function goToScreen(string:String):void {
			
			switch(string) {
				case "MainMenu": new_screen = new MainMenu(par); break;
				case "SelectMenu": new_screen = new SelectMenu(par); break;
				case "NextLevelMenu": new_screen = new NextLevelMenu(par); break;
				case "RetryMenu": new_screen = new RetryMenu(par); break;
				case "WinMenu": new_screen = new WinMenu(par); break;
				case "Game": new_screen = new Game(par); break;
			}
			
			if (current_screen != null) 
			{
				par.removeChild(current_screen);
			}
			
			current_screen = new_screen;
			par.addChild(current_screen);
		}
		
		public function select_text():void {
			rnd_num= Math.random();
			if (rnd_num < 0.3) {
				var txt1:ByteArray = new dog_text() as ByteArray;
				title = "El Perro sin Pelo";
				text = txt1.toString();
				question1 = "¿De que colores pueden ser los perros sin pelo peruanos?";
				q1answer1 = "Azules y rosados";
				q1answer2 = "Amarillos y grises";
				q1answer3 = "Rojos y anaranjados";
				q1answer4 = "Grises y rosados";
				question2 = "¿Con que otra raza de perro lo confunden?";
				q2answer1 = "Shitzu";
				q2answer2 = "Doberman";
				q2answer3 = "Chinos";
				q2answer4 = "Pastores alemanes";
				question3 = "¿Quienes los pintaban en muros y ceramicas?";
				q3answer1 = "Los limeños";
				q3answer2 = "Los chimues y mochicas";
				q3answer3 = "Los incas";
				q3answer4 = "Los Chavines";
				
				right_answer1 = 4;
				right_answer2 = 3;
				right_answer3 = 2;
				
			}
			if (rnd_num >= 0.3 && rnd_num < 0.6) {
				var txt2:ByteArray = new croc_text() as ByteArray;
				title = "Coco , el Cocodrilo de Tumbes";
				text = txt2.toString();
				question1 = "¿Que tamaño pueden alcanzar los cocodrilos de Tumbes?";
				q1answer1 = "3 metros";
				q1answer2 = "2 metros";
				q1answer3 = "6 metros";
				q1answer4 = "8 metros";
				question2 = "¿Donde vive Coco?";
				q2answer1 = "En los manglares";
				q2answer2 = "En los rios";
				q2answer3 = "En la selva";
				q2answer4 = "En los campos";
				question3 = "¿Que le gusta hacer a Coco?";
				q3answer1 = "Descansar en la sombra";
				q3answer2 = "Nadar en el rio con sus amigos";
				q3answer3 = "Asustar a las personas";
				q3answer4 = "Pasear por la selva";
				
				right_answer1 = 3;
				right_answer2 = 1;
				right_answer3 = 2;
				
			}
			
			if (rnd_num >= 0.6) {
				var txt3:ByteArray = new bull_text() as ByteArray;
				title = "El toro encantado de Huanta";
				text = txt3.toString();
				question1 = "¿En que laguna se encuentra el toro?";
				q1answer1 = "Laguna Conococha";
				q1answer2 = "Laguna Turquesa";
				q1answer3 = "Laguna Rasuhuillca";
				q1answer4 = "Laguna Churup";
				question2 = "¿Quien tenia atrapado al toro?";
				q2answer1 = "Un hombre";
				q2answer2 = "Una anciana";
				q2answer3 = "Los habitantes de las montañas";
				q2answer4 = "Una criatura de la laguna";
				question3 = "¿Que paso cuando escapo el toro?";
				q3answer1 = "Alcanzo su libertad";
				q3answer2 = "Pudo comer cuanto queria";
				q3answer3 = "Hubo una celebración";
				q3answer4 = "La laguna inundo el valle";
				
				right_answer1 = 3;
				right_answer2 = 2;
				right_answer3 = 4;
				
			}
			
		}
		
	}

}